In [26]:
!pip install yfinance
!pip install pandas
!pip install requests
!pip install bs4
!pip install plotly
!pip install html5lib
!pip install lxml
!mamba install bs4==4.10.0 -y
!pip install lxml==4.6.4
!mamba install html5lib==1.1 -y
Requirement already satisfied: yfinance in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (0.1.74)
Requirement already satisfied: pandas>=0.24.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance) (1.3.5)
Requirement already satisfied: lxml>=4.5.1 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance) (4.9.1)
Requirement already satisfied: multitasking>=0.0.7 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance) (0.0.11)
Requirement already satisfied: numpy>=1.15 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance) (1.21.6)
Requirement already satisfied: requests>=2.26 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance) (2.28.1)
Requirement already satisfied: python-dateutil>=2.7.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pandas>=0.24.0->yfinance) (2.8.2)
Requirement already satisfied: pytz>=2017.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pandas>=0.24.0->yfinance) (2022.2.1)
Requirement already satisfied: charset-normalizer<3,>=2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.26->yfinance) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.26->yfinance) (2022.6.15)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.26->yfinance) (1.26.11)
Requirement already satisfied: idna<4,>=2.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.26->yfinance) (3.3)
Requirement already satisfied: six>=1.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas>=0.24.0->yfinance) (1.16.0)
Requirement already satisfied: pandas in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (1.3.5)
Requirement already satisfied: python-dateutil>=2.7.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2017.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pandas) (2022.2.1)
Requirement already satisfied: numpy>=1.17.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pandas) (1.21.6)
Requirement already satisfied: six>=1.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas) (1.16.0)
Requirement already satisfied: requests in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (2.28.1)
Requirement already satisfied: charset-normalizer<3,>=2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests) (2022.6.15)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests) (1.26.11)
Requirement already satisfied: idna<4,>=2.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests) (3.3)
Requirement already satisfied: bs4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from bs4) (4.11.1)
Requirement already satisfied: soupsieve>1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from beautifulsoup4->bs4) (2.3.2.post1)
Requirement already satisfied: plotly in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (5.10.0)
Requirement already satisfied: tenacity>=6.2.0 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from plotly) (8.0.1)
Requirement already satisfied: html5lib in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (1.1)
Requirement already satisfied: webencodings in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from html5lib) (0.5.1)
Requirement already satisfied: six>=1.9 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from html5lib) (1.16.0)
Requirement already satisfied: lxml in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (4.9.1)

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (0.15.3) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['bs4==4.10.0']

pkgs/main/linux-64       [<=>                 ] (00m:00s) 
pkgs/main/linux-64       [=>                ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/linux-64       [=>                ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/noarch         [<=>                 ] (00m:00s) 
pkgs/main/linux-64       [=>                ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/noarch         [=>                ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/main/linux-64       [=>                ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/noarch         [=>                ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/r/linux-64          [<=>                 ] (00m:00s) 
pkgs/main/linux-64       [=>                ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/noarch         [=>                ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/r/linux-64          [=>                ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/main/linux-64       [=>                ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/noarch         [=>                ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/r/linux-64          [=>                ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/r/noarch            [<=>                 ] (00m:00s) 
pkgs/main/linux-64       [=>                ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/noarch         [=>                ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/r/linux-64          [=>                ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/r/noarch            [=>                ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [<=>               ] (00m:00s) 532 KB / ?? (1.71 MB/s)
pkgs/main/noarch         [=>                ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/r/linux-64          [=>                ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/r/noarch            [=>                ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [=>                ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/r/linux-64          [=>                ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/r/noarch            [=>                ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 336 KB / ?? (1.08 MB/s)
pkgs/r/linux-64          [=>                ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/r/noarch            [=>                ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/linux-64          [=>                ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/r/noarch            [=>                ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/linux-64          [<=>               ] (00m:00s) 608 KB / ?? (1.95 MB/s)
pkgs/r/noarch            [=>                ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/linux-64          [ <=>                ] (00m:00s) 1 MB / ?? (2.82 MB/s)
pkgs/r/noarch            [=>                ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/linux-64          [ <=>                ] (00m:00s) 1 MB / ?? (2.82 MB/s)
pkgs/r/noarch            [<=>               ] (00m:00s) 580 KB / ?? (1.86 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/linux-64          [ <=>                ] (00m:00s) 1 MB / ?? (2.82 MB/s)
pkgs/r/noarch            [ <=>                ] (00m:00s) 1 MB / ?? (2.56 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/linux-64          [ <=>                ] (00m:00s) Finalizing...
pkgs/r/noarch            [ <=>                ] (00m:00s) 1 MB / ?? (2.56 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/linux-64          [ <=>                ] (00m:00s) Done
pkgs/r/noarch            [ <=>                ] (00m:00s) 1 MB / ?? (2.56 MB/s)
pkgs/r/linux-64          [====================] (00m:00s) Done
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/noarch            [ <=>                ] (00m:00s) 1 MB / ?? (2.56 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/noarch            [ <=>                ] (00m:00s) Finalizing...
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/r/noarch            [ <=>                ] (00m:00s) Done
pkgs/r/noarch            [====================] (00m:00s) Done
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [<=>               ] (00m:00s) 748 KB / ?? (1.60 MB/s)
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [ <=>                ] (00m:00s) Finalizing...
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/noarch         [ <=>                ] (00m:00s) Done
pkgs/main/noarch         [====================] (00m:00s) Done
pkgs/main/linux-64       [ <=>                ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/linux-64       [  <=>               ] (00m:00s) 1 MB / ?? (2.42 MB/s)
pkgs/main/linux-64       [  <=>               ] (00m:00s) 2 MB / ?? (3.05 MB/s)
pkgs/main/linux-64       [   <=>              ] (00m:00s) 2 MB / ?? (3.05 MB/s)
pkgs/main/linux-64       [   <=>              ] (00m:00s) 2 MB / ?? (3.23 MB/s)
pkgs/main/linux-64       [    <=>             ] (00m:00s) 2 MB / ?? (3.23 MB/s)
pkgs/main/linux-64       [    <=>             ] (00m:00s) 3 MB / ?? (3.37 MB/s)
pkgs/main/linux-64       [     <=>            ] (00m:00s) 3 MB / ?? (3.37 MB/s)
pkgs/main/linux-64       [     <=>            ] (00m:00s) 4 MB / ?? (3.46 MB/s)
pkgs/main/linux-64       [      <=>           ] (00m:00s) 4 MB / ?? (3.46 MB/s)
pkgs/main/linux-64       [      <=>           ] (00m:00s) 4 MB / ?? (3.57 MB/s)
pkgs/main/linux-64       [      <=>           ] (00m:00s) Finalizing...
pkgs/main/linux-64       [      <=>           ] (00m:01s) Done
pkgs/main/linux-64       [====================] (00m:01s) Done

Pinned packages:
  - python 3.7.*


Transaction

  Prefix: /home/jupyterlab/conda/envs/python

  Updating specs:

   - bs4==4.10.0
   - ca-certificates
   - certifi
   - openssl


  Package               Version  Build           Channel                  Size
────────────────────────────────────────────────────────────────────────────────
  Install:
────────────────────────────────────────────────────────────────────────────────

  + bs4                  4.10.0  hd3eb1b0_0      pkgs/main/noarch        10 KB

  Change:
────────────────────────────────────────────────────────────────────────────────

  - certifi           2022.6.15  py37h89c1867_0  installed                    
  + certifi           2022.6.15  py37h06a4308_0  pkgs/main/linux-64     153 KB
  - openssl              1.1.1q  h166bdaf_0      installed                    
  + openssl              1.1.1q  h7f8727e_0      pkgs/main/linux-64       3 MB

  Upgrade:
────────────────────────────────────────────────────────────────────────────────

  - ca-certificates   2022.6.15  ha878542_0      installed                    
  + ca-certificates  2022.07.19  h06a4308_0      pkgs/main/linux-64     124 KB

  Downgrade:
────────────────────────────────────────────────────────────────────────────────

  - beautifulsoup4       4.11.1  pyha770c72_0    installed                    
  + beautifulsoup4       4.10.0  pyh06a4308_0    pkgs/main/noarch        85 KB

  Summary:

  Install: 1 packages
  Change: 2 packages
  Upgrade: 1 packages
  Downgrade: 1 packages

  Total download: 3 MB

────────────────────────────────────────────────────────────────────────────────

Downloading  [>                                        ] (00m:00s)   38.64 KB/s
Extracting   [>                                                      ] (--:--) 
Finished bs4                                  (00m:00s)              10 KB     39 KB/s
Downloading  [>                                        ] (00m:00s)   38.64 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [>                                        ] (00m:00s)   38.64 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [>                                        ] (00m:00s)   38.64 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [=>                                       ] (00m:00s)  362.19 KB/s
Extracting   [>                                                      ] (--:--) 
Finished beautifulsoup4                       (00m:00s)              85 KB    323 KB/s
Downloading  [=>                                       ] (00m:00s)  362.19 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [==>                                      ] (00m:00s)  833.19 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [==>                                      ] (00m:00s)  833.19 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [>                                                      ] (--:--) 
Finished ca-certificates                      (00m:00s)             124 KB    471 KB/s
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [>                                                      ] (--:--) 
Finished certifi                              (00m:00s)             153 KB    579 KB/s
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [========>                                ] (00m:00s)        1 / 5
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [========>                                ] (00m:00s)        1 / 5
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [================>                        ] (00m:00s)        2 / 5
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [================>                        ] (00m:00s)        2 / 5
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [========================>                ] (00m:00s)        3 / 5
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [========================>                ] (00m:00s)        3 / 5
Downloading  [====>                                    ] (00m:00s)    1.37 MB/s
Extracting   [================================>        ] (00m:00s)        4 / 5
Downloading  [===================>                     ] (00m:00s)    4.50 MB/s
Extracting   [================================>        ] (00m:00s)        4 / 5
Downloading  [===================>                     ] (00m:00s)    4.50 MB/s
Extracting   [================================>        ] (00m:00s)        4 / 5
Downloading  [=========================================] (00m:00s)    8.78 MB/s
Extracting   [================================>        ] (00m:00s)        4 / 5
Finished openssl                              (00m:00s)               3 MB      8 MB/s
Downloading  [=========================================] (00m:00s)    8.78 MB/s
Extracting   [================================>        ] (00m:00s)        4 / 5
Downloading  [=========================================] (00m:00s)    8.78 MB/s
Extracting   [================================>        ] (00m:00s)        4 / 5
Downloading  [=========================================] (00m:00s)    8.78 MB/s
Extracting   [================================>        ] (00m:00s)        4 / 5
Downloading  [=========================================] (00m:00s)    8.78 MB/s
Extracting   [=========================================] (00m:00s)        5 / 5
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Collecting lxml==4.6.4
  Downloading lxml-4.6.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (6.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.3/6.3 MB 85.1 MB/s eta 0:00:00:00:0100:01
Installing collected packages: lxml
  Attempting uninstall: lxml
    Found existing installation: lxml 4.9.1
    Uninstalling lxml-4.9.1:
      Successfully uninstalled lxml-4.9.1
Successfully installed lxml-4.6.4

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (0.15.3) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['html5lib==1.1']

pkgs/main/linux-64       Using cache
pkgs/main/noarch         Using cache
pkgs/r/linux-64          Using cache
pkgs/r/noarch            Using cache

Pinned packages:
  - python 3.7.*


Transaction

  Prefix: /home/jupyterlab/conda/envs/python

  Updating specs:

   - html5lib==1.1
   - ca-certificates
   - certifi
   - openssl


  Package         Version  Build         Channel                 Size
───────────────────────────────────────────────────────────────────────
  Install:
───────────────────────────────────────────────────────────────────────

  + html5lib          1.1  pyhd3eb1b0_0  pkgs/main/noarch       91 KB
  + webencodings    0.5.1  py37_1        pkgs/main/linux-64     19 KB

  Summary:

  Install: 2 packages

  Total download: 110 KB

───────────────────────────────────────────────────────────────────────

Downloading  [======>                                  ] (00m:00s)   75.47 KB/s
Extracting   [>                                                      ] (--:--) 
Finished webencodings                         (00m:00s)              19 KB     75 KB/s
Downloading  [======>                                  ] (00m:00s)   75.47 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [======>                                  ] (00m:00s)   75.47 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [======>                                  ] (00m:00s)   75.47 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [======>                                  ] (00m:00s)   75.47 KB/s
Extracting   [====================>                    ] (00m:00s)        1 / 2
Downloading  [=========================================] (00m:00s)  248.68 KB/s
Extracting   [====================>                    ] (00m:00s)        1 / 2
Finished html5lib                             (00m:00s)              91 KB    205 KB/s
Downloading  [=========================================] (00m:00s)  248.68 KB/s
Extracting   [====================>                    ] (00m:00s)        1 / 2
Downloading  [=========================================] (00m:00s)  248.68 KB/s
Extracting   [====================>                    ] (00m:00s)        1 / 2
Downloading  [=========================================] (00m:00s)  248.68 KB/s
Extracting   [====================>                    ] (00m:00s)        1 / 2
Downloading  [=========================================] (00m:00s)  248.68 KB/s
Extracting   [=========================================] (00m:00s)        2 / 2
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
In [28]:
import yfinance as yf
import pandas as pd
import requests
from bs4 import BeautifulSoup
import plotly.graph_objects as go
from plotly.subplots import make_subplots
In [36]:
def make_graph(stock_data, revenue_data, stock):
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=("Historical Share Price", "Historical Revenue"), vertical_spacing = .3)
    fig.add_trace(go.Scatter(x=pd.to_datetime(stock_data.Date, infer_datetime_format=True), y=stock_data.Close.astype("float"), name="Share Price"), row=1, col=1)
    fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data.Date, infer_datetime_format=True), y=revenue_data.Revenue.astype("float"), name="Revenue"), row=2, col=1)
    fig.update_xaxes(title_text="Date", row=1, col=1)
    fig.update_xaxes(title_text="Date", row=2, col=1)
    fig.update_yaxes(title_text="Price ($US)", row=1, col=1)
    fig.update_yaxes(title_text="Revenue ($US Millions)", row=2, col=1)
    fig.update_layout(showlegend=False,
    height=900,
    title=stock,
    xaxis_rangeslider_visible=True)
    fig.show()

Question 1 - Extracting Tesla Stock Data Using yfinance¶

In [37]:
tesla = yf.Ticker('TSLA')
In [39]:
tesla_data = tesla.history(period="max")
tesla_data.reset_index(inplace=True)
tesla_data.head()
Out[39]:
Date Open High Low Close Volume Dividends Stock Splits
0 2010-06-29 3.800 5.000 3.508 4.778 93831500 0 0.0
1 2010-06-30 5.158 6.084 4.660 4.766 85935500 0 0.0
2 2010-07-01 5.000 5.184 4.054 4.392 41094000 0 0.0
3 2010-07-02 4.600 4.620 3.742 3.840 25699000 0 0.0
4 2010-07-06 4.000 4.000 3.166 3.222 34334500 0 0.0

Question 2 - Extracting Tesla Revenue Data Using Webscraping¶

In [40]:
url = 'https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue'
html_data = requests.get(url).text
In [42]:
soup = BeautifulSoup(html_data,"lxml")
In [43]:
tesla_revenue = pd.DataFrame(columns=['Date', 'Revenue'])

for table in soup.find_all('table'):

    if ('Tesla Quarterly Revenue' in table.find('th').text):
        rows = table.find_all('tr')
        
        for row in rows:
            col = row.find_all('td')
            
            if col != []:
                date = col[0].text
                revenue = col[1].text.replace(',','').replace('$','')

                tesla_revenue = tesla_revenue.append({"Date":date, "Revenue":revenue}, ignore_index=True)
In [44]:
tesla_revenue
Out[44]:
Date Revenue
0 2022-06-30 16934
1 2022-03-31 18756
2 2021-12-31 17719
3 2021-09-30 13757
4 2021-06-30 11958
5 2021-03-31 10389
6 2020-12-31 10744
7 2020-09-30 8771
8 2020-06-30 6036
9 2020-03-31 5985
10 2019-12-31 7384
11 2019-09-30 6303
12 2019-06-30 6350
13 2019-03-31 4541
14 2018-12-31 7226
15 2018-09-30 6824
16 2018-06-30 4002
17 2018-03-31 3409
18 2017-12-31 3288
19 2017-09-30 2985
20 2017-06-30 2790
21 2017-03-31 2696
22 2016-12-31 2285
23 2016-09-30 2298
24 2016-06-30 1270
25 2016-03-31 1147
26 2015-12-31 1214
27 2015-09-30 937
28 2015-06-30 955
29 2015-03-31 940
30 2014-12-31 957
31 2014-09-30 852
32 2014-06-30 769
33 2014-03-31 621
34 2013-12-31 615
35 2013-09-30 431
36 2013-06-30 405
37 2013-03-31 562
38 2012-12-31 306
39 2012-09-30 50
40 2012-06-30 27
41 2012-03-31 30
42 2011-12-31 39
43 2011-09-30 58
44 2011-06-30 58
45 2011-03-31 49
46 2010-12-31 36
47 2010-09-30 31
48 2010-06-30 28
49 2010-03-31 21
50 2009-12-31
51 2009-09-30 46
52 2009-06-30 27
In [45]:
tesla_revenue = tesla_revenue[tesla_revenue['Revenue'].astype(bool)]
In [46]:
tesla_revenue.tail()
Out[46]:
Date Revenue
47 2010-09-30 31
48 2010-06-30 28
49 2010-03-31 21
51 2009-09-30 46
52 2009-06-30 27

Question 3 - Extracting GameStop Stock Data Using yfinance¶

In [47]:
gme = yf.Ticker('GME')
In [48]:
gme_data = gme.history(period='max')
In [49]:
gme_data.reset_index(inplace=True)
gme_data.head()
Out[49]:
Date Open High Low Close Volume Dividends Stock Splits
0 2002-02-13 1.620129 1.693350 1.603296 1.691667 76216000 0.0 0.0
1 2002-02-14 1.712707 1.716074 1.670626 1.683250 11021600 0.0 0.0
2 2002-02-15 1.683250 1.687458 1.658001 1.674834 8389600 0.0 0.0
3 2002-02-19 1.666418 1.666418 1.578047 1.607504 7410400 0.0 0.0
4 2002-02-20 1.615920 1.662210 1.603296 1.662210 6892800 0.0 0.0

Question 4 - Extracting GameStop Revenue Data Using Webscraping¶

In [57]:
url = 'https://www.macrotrends.net/stocks/charts/GME/gamestop/revenue'
html_data = requests.get(url).text
In [65]:
!pip install bs4
!mamba install html5lib==1.1 -y
from bs4 import BeautifulSoup # this module helps in web scrapping.
import requests
Requirement already satisfied: bs4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from bs4) (4.10.0)
Requirement already satisfied: soupsieve>1.2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from beautifulsoup4->bs4) (2.3.2.post1)

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (0.15.3) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['html5lib==1.1']

pkgs/main/linux-64       [>                   ] (--:--) No change
pkgs/main/linux-64       [====================] (00m:00s) No change
pkgs/main/noarch         [>                   ] (--:--) No change
pkgs/main/noarch         [====================] (00m:00s) No change
pkgs/r/linux-64          [>                   ] (--:--) No change
pkgs/r/linux-64          [====================] (00m:00s) No change
pkgs/r/noarch            [>                   ] (--:--) No change
pkgs/r/noarch            [====================] (00m:00s) No change

Pinned packages:
  - python 3.7.*


Transaction

  Prefix: /home/jupyterlab/conda/envs/python

  All requested packages already installed

In [69]:
soup = BeautifulSoup(html_data,"lxml")
In [71]:
gme_revenue = pd.DataFrame(columns=['Date', 'Revenue'])

for table in soup.find_all('table'):

    if ('GameStop Quarterly Revenue' in table.find('th').text):
        rows = table.find_all('tr')
        
        for row in rows:
            col = row.find_all('td')
            
            if col != []:
                date = col[0].text
                revenue = col[1].text.replace(',','').replace('$','')

                gme_revenue = gme_revenue.append({"Date":date, "Revenue":revenue}, ignore_index=True)
In [72]:
gme_revenue.tail()
Out[72]:
Date Revenue
49 2010-01-31 3524
50 2009-10-31 1835
51 2009-07-31 1739
52 2009-04-30 1981
53 2009-01-31 3492

Question 5 - Tesla Stock and Revenue Dashboard¶

In [73]:
make_graph(tesla_data[['Date','Close']], tesla_revenue, 'Tesla')

Question 6 - GameStop Stock and Revenue Dashboard¶

In [74]:
make_graph(gme_data[['Date','Close']], gme_revenue, 'GameStop')
In [ ]: